package com.ruoyi.web.controller.union;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.union.domain.Association;
import com.ruoyi.union.service.IAssociationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/union/association")
public class AssociationController extends BaseController {

    @Resource
    private IAssociationService associationService;

    @GetMapping("/list")
    public TableDataInfo list(Association query) {
        startPage();
        List<Association> list = associationService.selectAssociationList(query);
        return getDataTable(list);
    }

    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(associationService.selectAssociationById(id));
    }

    @PostMapping
    public AjaxResult add(@RequestBody Association body) {
        return toAjax(associationService.insertAssociation(body));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody Association body) {
        return toAjax(associationService.updateAssociation(body));
    }

    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(associationService.deleteAssociationByIds(ids));
    }
}


